var mysql = require("mysql"); //引入第三方模块

//创建连接池
var pool = mysql.createPool({
  host: "localhost",
  user: "root", //登录数据库用户名
  password: "root", //登录数据库密码
  port: 3306,
  database: "h52004", //数据库名
  multipleStatements: true, //允许创建多个连接对象
});

//写查询语句
pool.query("SELECT * FROM user_inf", (err, res) => {
  if (err) {
    console.log(err);
    return;
  }

  console.log(res); //[{},{}]
  let str = JSON.stringify(res); //转成字符串打印
  console.log(str);
});
